package chatServerMain;

import java.io.*;
import java.net.MalformedURLException;
import java.rmi.RemoteException;

import chat.model.*;
import chatServer.view.*;
import chatServer.controller.*;

public class ChatServerMain {
	
	public static void main(String []args) throws RemoteException, MalformedURLException
	{
		ChatServerController server = new ChatServerController();
		server.ReadServerFile(ApplicationConstant.serverFile);
		
		//while there is an active server, we will be the backup server.
		while (server.checkActiveServer())
		{
			//cause the delay so we don't cause too much traffic in the network.
			try {
				Thread.sleep(ApplicationConstant.DEFAULT_SLEEP_TIME);
			} catch (InterruptedException e) {				
				e.printStackTrace();
			}
		}
		
		//when there is no active server then we become the active server.
		server.start();
	}
}